
pub trait PayStrategy {
    fn pay_info(&self) -> String;
}

pub struct Alipay{
    pub key:String,
    pub app_id:String,
}

pub struct WechatPay{
    pub key:String,
    pub app_id:String,
}

impl PayStrategy for Alipay{
    fn pay_info(&self) -> String {
        format!("alipay key:{},app_id:{}",self.key,self.app_id)
    }
}

impl PayStrategy for WechatPay{
    fn pay_info(&self) -> String{
        format!("wechat pay key:{},app_id:{}",self.key,self.app_id)
    }
}

pub enum PayType{
    ALIPAY,
    WECHATPAY,
}

impl PayType {
    pub fn new(&self) -> Box<dyn PayStrategy> {
        match self {
            PayType::ALIPAY => Box::new(Alipay{
                app_id: "app_id_123".to_string(),
                key: "alipay_key_123".to_string()
            }),
            PayType::WECHATPAY => Box::new(WechatPay{
                app_id: "app_id_123".to_string(),
                key: "wechat_key_123".to_string()
            }),
        }
    }
    pub fn get_pay_info(&self,)->String {
        self.new().pay_info()
    }
}
